const express=require('express');

var app=express();
//

//接收用户请求
app.get('/api', (req, res)=>{
  //查询banner的东西
  res.json({a:'1'});

});
app.post('/api',(req,res)=>{
  var str='';
  req.on('data', function (data){
    str+=data;
  });
  req.on('end', function (){
    console.log(str);
    res.send('123');
  });
})


//4.static数据 指定静态资源访问目录 下面为静态文件方法 不可改
app.listen(3000);

var server = app.listen(3001,"localhost",function(){
  var host = server.address().address;
  var port = server.address().port;
  console.log("Server running at http://%s:%s", host, port)
});